package com.fbs.wowo.finance.mapper;

import com.fbs.wowo.finance.entity.Payment;
import org.apache.ibatis.jdbc.SQL;

public class PaymentSqlProvider {

    public String insertSelective(Payment record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("payment");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=VARCHAR}");
        }
        
        if (record.getBody() != null) {
            sql.VALUES("body", "#{body,jdbcType=VARCHAR}");
        }
        
        if (record.getTradeNo() != null) {
            sql.VALUES("trade_no", "#{tradeNo,jdbcType=VARCHAR}");
        }
        
        if (record.getTransactionId() != null) {
            sql.VALUES("transaction_id", "#{transactionId,jdbcType=VARCHAR}");
        }
        
        if (record.getBuyerId() != null) {
            sql.VALUES("buyer_id", "#{buyerId,jdbcType=VARCHAR}");
        }
        
        if (record.getTotalFee() != null) {
            sql.VALUES("total_fee", "#{totalFee,jdbcType=DECIMAL}");
        }
        
        if (record.getTimeStart() != null) {
            sql.VALUES("time_start", "#{timeStart,jdbcType=TIMESTAMP}");
        }
        
        if (record.getTradeType() != null) {
            sql.VALUES("trade_type", "#{tradeType,jdbcType=TINYINT}");
        }
        
        if (record.getProductId() != null) {
            sql.VALUES("product_id", "#{productId,jdbcType=VARCHAR}");
        }
        
        if (record.getProductCategory() != null) {
            sql.VALUES("product_category", "#{productCategory,jdbcType=TINYINT}");
        }
        
        if (record.getProductType() != null) {
            sql.VALUES("product_type", "#{productType,jdbcType=TINYINT}");
        }
        
        if (record.getStatus() != null) {
            sql.VALUES("status", "#{status,jdbcType=TINYINT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Payment record) {
        SQL sql = new SQL();
        sql.UPDATE("payment");
        
        if (record.getBody() != null) {
            sql.SET("body = #{body,jdbcType=VARCHAR}");
        }
        
        if (record.getTradeNo() != null) {
            sql.SET("trade_no = #{tradeNo,jdbcType=VARCHAR}");
        }
        
        if (record.getTransactionId() != null) {
            sql.SET("transaction_id = #{transactionId,jdbcType=VARCHAR}");
        }
        
        if (record.getBuyerId() != null) {
            sql.SET("buyer_id = #{buyerId,jdbcType=VARCHAR}");
        }
        
        if (record.getTotalFee() != null) {
            sql.SET("total_fee = #{totalFee,jdbcType=DECIMAL}");
        }
        
        if (record.getTimeStart() != null) {
            sql.SET("time_start = #{timeStart,jdbcType=TIMESTAMP}");
        }
        
        if (record.getTradeType() != null) {
            sql.SET("trade_type = #{tradeType,jdbcType=TINYINT}");
        }
        
        if (record.getProductId() != null) {
            sql.SET("product_id = #{productId,jdbcType=VARCHAR}");
        }
        
        if (record.getProductCategory() != null) {
            sql.SET("product_category = #{productCategory,jdbcType=TINYINT}");
        }
        
        if (record.getProductType() != null) {
            sql.SET("product_type = #{productType,jdbcType=TINYINT}");
        }
        
        if (record.getStatus() != null) {
            sql.SET("status = #{status,jdbcType=TINYINT}");
        }
        
        sql.WHERE("id = #{id,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}